home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / STIME.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  989 b   |  32 lines

  1. /* stime.c        Turbo C Bible Functions, p. 336        */
  2. #include <stdio.h>
  3. #include <dos.h>
  4. #include <time.h>
  5. main()
  6. {
  7.     int d, m, y, h, min, sec;
  8.     long uxtime;
  9.     struct date date;
  10.     struct time time;
  11.     getdate(&date);
  12.         /* Get current data and time and prompt for new values */
  13.     printf("The date is %d-%d-%d\nEnter new date:",
  14.                    date.da_mon, date.da_day, date.da_year);
  15.     scanf(" %d-%d-%d", &m, &d, &y);
  16.     gettime(&time);
  17.     printf("Current time is %02d:%02d:%02d\nEnter new time:",
  18.                 time.ti_hour, time.ti_min, time.ti_sec);
  19.     scanf(" %d: %d: %d", &h, &min, &sec);
  20.     date.da_year = y;
  21.         /* Copy date and time into the date and time structures    */
  22.     date.da_mon = m;
  23.     date.da_day = d;
  24.     time.ti_hour = h;
  25.     time.ti_min = min;
  26.     time.ti_sec = sec;
  27.     uxtime = dostounix(&date, &time);
  28.                 /* Convert date and time to UNIX format    */
  29.     stime(&uxtime);        /* Set date and time using stime    */
  30.     printf("Date and time set.  Verify using DOS"
  31.            " commands DATE and TIME\n");
  32. }